#define NULL 0 #define BUFFLENGTH 64 // String recvbufer length. #include <p18f452.h> #pragma config WDT = OFF //Global variables volatile unsigned char recvbuf[BUFFLENGTH]; volatile unsigned char* recvbuf_iPtr; volatile unsigned char* recvbuf_ePtr; //Function Prototypes void Setup(void); void high_isr(void); //Interrupt declaration. #pragma code high_vector=0x0008 void interruptHigh(void) { _asm GOTO high_isr _endasm } #pragma code //**************************************************************** void main (void) { recvbuf_iPtr = &recvbuf[0]; //initialise insertion pointer recvbuf_ePtr = &recvbuf[0]; //initialise removal pointer Setup(); while (1) { // do nothing. } } void high_isr(void) { INTCONbits.GIE = 0; // Catch interrupt PIR1bits.RCIF = 0; // Clear RC flag if (RCREG == 0x0D | RCREG == 0x0A) { // Place special handling for 'enter' here. } *recvbuf_iPtr = RCREG; // Place recieved char into insertion location recvbuf_iPtr = recvbuf_iPtr++; // Increment insertion pointer. if (recvbuf_iPtr >= recvbuf + BUFFLENGTH) { recvbuf_iPtr = recvbuf; } INTCONbits.GIE = 1; // reset interrupt - clear flag etc. } void Setup(void) { TXSTAbits.BRGH = 1; SPBRG = 25; // Baud rate at 9600 TRISCbits.TRISC6 = 0; // PortC 6 is input TXSTAbits.SYNC = 0; // Asynchronous mode RCSTAbits.SPEN = 1; // Enable serial port // Initialise RS232 RC - with interrupts PIR1bits.RCIF = 0; // Clear RC flag PIE1bits.RCIE = 1; // Enable RC interrupt. IPR1bits.RCIP = 1; // High Priority for RC interrupts RCSTAbits.CREN = 1; // Enable RC INTCONbits.PEIE = 1; INTCONbits.GIE = 1; // Enabling interrupts }
You need to enable Javascript in your browser to edit pages.
help on how to format text
See Global Variables
#define NULL 0 #define BUFFLENGTH 64 // String recvbufer length. #include <p18f452.h> #pragma config WDT = OFF //Global variables volatile unsigned char recvbuf[BUFFLENGTH]; volatile unsigned char* recvbuf_iPtr; volatile unsigned char* recvbuf_ePtr; //Function Prototypes void Setup(void); void high_isr(void); //Interrupt declaration. #pragma code high_vector=0x0008 void interruptHigh(void) { _asm GOTO high_isr _endasm } #pragma code //**************************************************************** void main (void) { recvbuf_iPtr = &recvbuf[0]; //initialise insertion pointer recvbuf_ePtr = &recvbuf[0]; //initialise removal pointer Setup(); while (1) { // do nothing. } } void high_isr(void) { INTCONbits.GIE = 0; // Catch interrupt PIR1bits.RCIF = 0; // Clear RC flag if (RCREG == 0x0D | RCREG == 0x0A) { // Place special handling for 'enter' here. } *recvbuf_iPtr = RCREG; // Place recieved char into insertion location recvbuf_iPtr = recvbuf_iPtr++; // Increment insertion pointer. if (recvbuf_iPtr >= recvbuf + BUFFLENGTH) { recvbuf_iPtr = recvbuf; } INTCONbits.GIE = 1; // reset interrupt - clear flag etc. } void Setup(void) { TXSTAbits.BRGH = 1; SPBRG = 25; // Baud rate at 9600 TRISCbits.TRISC6 = 0; // PortC 6 is input TXSTAbits.SYNC = 0; // Asynchronous mode RCSTAbits.SPEN = 1; // Enable serial port // Initialise RS232 RC - with interrupts PIR1bits.RCIF = 0; // Clear RC flag PIE1bits.RCIE = 1; // Enable RC interrupt. IPR1bits.RCIP = 1; // High Priority for RC interrupts RCSTAbits.CREN = 1; // Enable RC INTCONbits.PEIE = 1; INTCONbits.GIE = 1; // Enabling interrupts }